/*
 * Class Human.java
 * 9.06.2012
 * :)
 * Class represents human model, which consists of 
 * different organs and life characteristics.
 * Each life characteristics depends on multiple organ parameter,
 * which could be changed according live activity
 */

package humanMirror.model.human;

import humanMirror.model.questionLibrary.*;

import java.util.ArrayList;
import java.util.List;


/**
 * Class implements human like a list of organs and their characteristics
 * Depends on them changes live parameters which may cause death.
 * By default human initialized like a newborn with neutral parameters
 * (parameters varies from -100(worst) to +100(best).Neutral is 0;
 * 
 * @author Vasyl Khyzhniak
 * @version 1.2
 */
public class Human {
	private int totalLife;	
		
	private List<Organ> organs;
	/**
	 * Human Class Constructor
	 * Creates a "human" with newborn human parameter (they are equals to 0)
	 */
	public Human() {
		totalLife = 0;                
                organs = new ArrayList<Organ>();
                organs.add(new Brain());
                organs.add(new Liver());	
	}

	public int getTotalLife() {
		return totalLife;
	}
        
    public OrganParameters getOrganParametrs(String name){
        for (Organ organ : organs) {
            if (name.equals(organ.getName())) {
                return organ.getParametrs();
            }
        }
        return new OrganParameters();
    }
    
    public void setOrganParameters(OrganInfo sumArray)
    {
        organs.get(SomeConstants.BRAIN).changeHealth(sumArray.getParameter(SomeConstants.BRAIN, SomeConstants.HEALTH));
        ((Brain)organs.get(SomeConstants.BRAIN)).changeFatigue(sumArray.getParameter(SomeConstants.BRAIN, SomeConstants.ENERGY));
        ((Brain)organs.get(SomeConstants.BRAIN)).changeMemory(sumArray.getParameter(SomeConstants.BRAIN, SomeConstants.MEMORY));
        ((Brain)organs.get(SomeConstants.BRAIN)).changeOxygenation(sumArray.getParameter(SomeConstants.BRAIN, SomeConstants.OXYGENATION));
        
        organs.get(SomeConstants.LIVER).changeHealth(sumArray.getParameter(SomeConstants.LIVER, SomeConstants.HEALTH));
        ((Liver)organs.get(SomeConstants.LIVER)).changeDetoxification(sumArray.getParameter(SomeConstants.LIVER, SomeConstants.DETOXIFICATION));
        ((Liver)organs.get(SomeConstants.LIVER)).changeGlucose(sumArray.getParameter(SomeConstants.LIVER, SomeConstants.GLUCOSE));
        ((Liver)organs.get(SomeConstants.LIVER)).changeCholesterol(sumArray.getParameter(SomeConstants.LIVER, SomeConstants.CHOLESTEROL));
    }
}

